<script setup>
import baseModel from "@/components/baseModel/baseModel.vue";
import { computed, onMounted, reactive, ref, nextTick, watch } from "vue";
import img  from '@/views/shotstack/components/dialogComponent/img/loading.gif'
// const img = require("@/views/shotstack/components/dialogComponent/img/loading.gif");
import { message } from "ant-design-vue";

import {} from "@ant-design/icons-vue";

const dialog = ref(null);

const emit = defineEmits(["timerOver"]);

const overTime = ref(6);
const intervalId = ref(null);

// 是否展示确定按钮

const confige = reactive({
    showClose: true, // 是否展示关闭按钮
    content: '', // 提示内容
    subTitle: '', // 副标题
})

const timerRunStart = () => {
  intervalId.value = setInterval(() => {
    overTime.value--;
    if (overTime.value <= 0) {
        clearInterval(intervalId.value);
        emit("timerOver");
    }
  }, 1000);
};

const close = () => {
  clearInterval(intervalId.value);
  dialog.value.closeModal();
};

const closeModal = () => {
    clearInterval(intervalId.value);
    emit("timerOver");
}

const open = (params={}) => {
    // const { content = '', subTitle = '', showClose = true } = params
    Object.assign(confige, params)
    if (params.showClose) {
        overTime.value = 6;
        timerRunStart();
    }
    dialog.value.showModal();
};

defineExpose({
  open,
  close,
});
</script>

<template>
  <div class="audition">
    <!-- 
      :title="null"

     -->
    <baseModel
      ref="dialog"
      :contentWidth="'554px'"
      minWidth="554px"
      :zIndex="9999"
      :getContainer="() => document.queryselector('.audition')"
      :closable="false"
      :maskClosable="false"
    >
      <template #title> <div></div></template>
      <template #content>
        <div class="content">
          <img :src="img" class="title_img" alt="" />
          <p v-if="confige.showClose">
            合成进度请在 <span style="color: #1677ff; cursor:pointer" @click="closeModal">合成记录</span>中查看
          </p>
          <p v-else>{{confige.content}}</p>
          <span>{{confige.subTitle}}</span>
        </div>
      </template>
      <template #footer>
        <div class="bottom">
          <a-button v-if="confige.showClose" class="btn" key="submit" type="primary" @click="closeModal"
            >我知道啦({{ overTime }}s)</a-button
          >
        </div>
      </template>
    </baseModel>
  </div>
</template>

<style lang="less" scoped>
.title_box {
  span {
    font-size: 18px;
    color: #0c0d0e;
  }
}

.content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;

  .loding {
    margin-top: 50px;
  }

  .title_img {
    width: 120px;
    height: 120px;
    object-fit: contain;
  }

  p {
    font-weight: 600;
    font-size: 16px;
  }

  span {
    color: #888;
  }
}

.bottom {
  display: flex;

  .btn {
    margin-left: auto;
  }
}
</style>
